<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Rss extends MY_Controller {
	var $defaultLang;
	function __construct(){
		parent::__construct();
	}
	
	public function index(){
		$dir = $this->uri->segment(2);
		if($dir==''){
			$this->_index();
		}else{
			$thiscategory = $this->Cache_model->loadCategoryByDir($dir);
			if(!$thiscategory){
				show_404();
			}
			if($thiscategory['model']=='page'||$thiscategory['model']=='guestbook'){
				redirect(site_url('category/'.$dir.$this->Cache_model->langurl),'location',301);
			}else{
				$this->_list($thiscategory);
			}
		}
	}
	
	function _index(){
		$this->seo(lang('rss'),lang('rss'),lang('rss'));
		$this->view('rssindex');
	}
	
	function _list($thiscategory){
		$list = $this->Cache_model->loadModel($thiscategory['model'],$thiscategory['id'],'puttime',20,1);
		$this->seo($thiscategory['title']==''?$thiscategory['name']:$thiscategory['title'],
			$thiscategory['keywords']==''?$thiscategory['name']:$thiscategory['keywords'],
			$thiscategory['description']==''?'':$thiscategory['description']);
		$res = array(
				'list'=>$list,
				'category'=>$thiscategory,
				'current_url'=>site_url('category/'.$thiscategory['dir'].$this->Cache_model->langurl)
		);
		$this->view('rss',$res);
	}
}